<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/templates/tmpl_admin.xhtml">
	<ui:define name="centro">

		<h:form id="form">
			<p:messages id="messages" showDetail="true" autoUpdate="true"
				closable="true" />

			<br />

			<p:dataTable id="listaSprintBacklog" var="item"
				value="#{sprintBacklogMBean.itens}" paginator="true" rows="10"
				paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
				rowsPerPageTemplate="5,10,15" emptyMessage="Nenhum item cadastrado"
				filteredValue="#{sprintBacklogMBean.itensFiltro}"
				resizableColumns="true" selectionMode="single" rowKey="#{item.id}"
				selection="#{sprintBacklogMBean.sprintBacklog}">

				<p:ajax event="rowSelect" update=":form:formulario"
					oncomplete="itemDialog.show()"
					listener="#{sprintBacklogMBean.editar}" />

				<f:facet name="header">
					Lista da Sprint Backlog
				</f:facet>

				<p:column headerText="Código">
					<p:outputLabel value="#{item.id}" />
				</p:column>

				<p:column headerText="Título" sortBy="#{item.titulo}"
					filterBy="#{item.titulo}" filterMatchMode="contains">
					<p:outputLabel value="#{item.titulo}" />
				</p:column>

				<p:column headerText="Descrição">
					<p:outputLabel value="#{item.descricao}" />
				</p:column>

				<p:column headerText="Nível">
					<p:outputLabel value="#{item.nivel.descricao}" />
				</p:column>

				<p:column headerText="Papel">
					<p:outputLabel value="#{item.papel.descricao}" />
				</p:column>

				<p:column headerText="Ganho Scrums">
					<p:outputLabel value="#{item.ganhoScrums}" />
				</p:column>

				<p:column headerText="Ganho Experiência">
					<p:outputLabel value="#{item.ganhoExperiencia}" />
				</p:column>

				<p:column headerText="Dias Máximo p/ Conclusão">
					<p:outputLabel value="#{item.maxDiaConclusao}" />
				</p:column>

				<f:facet name="footer">
					<p:commandButton value="Novo" icon="ui-icon-plus"
						update=":form:formulario"
						actionListener="#{sprintBacklogMBean.novo}"
						oncomplete="itemDialog.show()" />
				</f:facet>
			</p:dataTable>

			<p:dialog header="Item Sprint Backlog" widgetVar="itemDialog"
				resizable="false" showEffect="clip" hideEffect="fold">
				<h:panelGrid id="formulario" columns="2" cellpadding="4">
					<p:outputLabel value="Título" />
					<p:inputText id="item"
						value="#{sprintBacklogMBean.sprintBacklog.titulo}" />

					<p:outputLabel value="Descrição" />
					<p:inputTextarea
						value="#{sprintBacklogMBean.sprintBacklog.descricao}"
						style="width:250px;height:100px" />

					<p:outputLabel value="Nível" />
					<p:selectOneMenu value="#{sprintBacklogMBean.sprintBacklog.nivel}"
						converter="#{nivelConverter}">
						<f:selectItem itemLabel="Selecione um nivel..." itemValue="" />
						<f:selectItems value="#{sprintBacklogMBean.niveis}" var="nivel"
							itemLabel="#{nivel.descricao}" itemValue="#{nivel}" />
					</p:selectOneMenu>

					<p:outputLabel value="Papel" />
					<p:selectOneMenu value="#{sprintBacklogMBean.sprintBacklog.papel}"
						converter="#{papelConverter2}">
						<f:selectItem itemLabel="Selecione um papel..." itemValue="" />
						<f:selectItems value="#{sprintBacklogMBean.papeis}" var="papel"
							itemLabel="#{papel.descricao}" itemValue="#{papel}" />
					</p:selectOneMenu>

					<p:outputLabel value="Ganho Scrums" />
					<p:inputText
						value="#{sprintBacklogMBean.sprintBacklog.ganhoScrums}" />

					<p:outputLabel value="Ganho Experiência" />
					<p:inputText
						value="#{sprintBacklogMBean.sprintBacklog.ganhoExperiencia}" />

					<p:outputLabel value="Dias Máximo p/ Conclusão" />
					<p:inputText
						value="#{sprintBacklogMBean.sprintBacklog.maxDiaConclusao}" />

					<p:commandButton actionListener="#{sprintBacklogMBean.salvar}"
						value="Salvar" update=":form:listaSprintBacklog"
						oncomplete="itemDialog.hide()" />

					<p:commandButton action="#{sprintBacklogMBean.deletar}"
						value="Deletar" rendered="#{sprintBacklogMBean.acao == 'editar'}"
						update=":form:listaSprintBacklog" oncomplete="itemDialog.hide()" />
				</h:panelGrid>
			</p:dialog>

		</h:form>

	</ui:define>
</ui:composition>

</html>
